package Lee_code;

import java.nio.channels.NonReadableChannelException;

/**
 * @author blh
 * @date 2024年07月12日 9:04
 */
public class Lee_328_712 {
    public ListNode oddEvenList(ListNode head) {
        ListNode dummySingle = new ListNode(-1);
        ListNode dummySingleTemp = dummySingle;
        ListNode dummyDouble = new ListNode(-1);
        ListNode dummyDoubleTemp = dummyDouble;
        while (head != null) {
            dummySingleTemp.next = head;
            dummySingleTemp = dummySingleTemp.next;
            head = head.next;
            dummySingleTemp.next=null;

            if (head != null) {
                dummyDoubleTemp.next = head;
                head = head.next;
                dummyDoubleTemp = dummyDoubleTemp.next;
                dummyDoubleTemp.next = null;

            }
            else {
                break;
            }
        }
        dummySingleTemp.next = dummyDouble.next;
        return dummySingle.next;
    }
}
